from flask import Flask
from .extensions import init_extensions
from .blueprints.auth_zyy.routes import auth_zyy
from .blueprints.main_zyy.routes import main_zyy
import os

def create_app(config_name='default'):
    """创建Flask应用"""
    app = Flask(__name__)
    
    # 加载配置
    from config import config
    app.config.from_object(config[config_name])
    
    # 初始化扩展
    init_extensions(app)
    
    # 注册蓝图
    app.register_blueprint(auth_zyy, url_prefix='/auth_zyy')
    app.register_blueprint(main_zyy)
    
    # 创建上传目录
    if not os.path.exists(app.config['UPLOAD_FOLDER']):
        os.makedirs(app.config['UPLOAD_FOLDER'])
    
    return app 